Component({
    data: {
        selected: 0,
        color: "#7A7E83",
        selectedColor: "#1296db",
        tabvalue: 0, // 默认页面
        tabList: [{
                "pagePath": "/pages/home/home",
                "text": "首页",
                "iconPath": "/pages/img/sy.png",
                "selectedIconPath": "/pages/img/ssy.png",
                value: 0
            },
            {
                "pagePath": "/pages/classification/classification",
                "text": "客服中心",
                "iconPath": "/pages/img/fl.png",
                "selectedIconPath": "/pages/img/sfl.png",
                value: 1
            },
            {
                "pagePath": "/pages/my/my",
                "text": "我的",
                "iconPath": "/pages/img/wd.png",
                "selectedIconPath": "/pages/img/swd.png",
                value: 2
            }
        ],
    },
    methods: {
        // 切换 tab 事件
        switchTab(e) {
            const app = getApp();
            const data = e.currentTarget.dataset.dataset;
            const path = data.pagePath;
            if(data.text == "我的"){
                let userInfo = app.getUserInfo()
                if (userInfo && userInfo.userNo) {
                  wx.switchTab({
                    url: path,
                  })
                } else {
                  wx.navigateTo({
                    url: '/pages/index/index',
                  })
                }
            }else{
                wx.switchTab({
                    url: path,
                })
            }
        },
    },
});